from common.base import open_browser
from page.list_page import ListPage
from page.login_page import LoginPage, url
import time
from common.register_data import RegisterData

class ListScript:
    def __init__(self,driver):
        self.rd = RegisterData()
        loginpage = LoginPage(driver)
        self.listpage = ListPage(driver)
        self.listpage.open_url(url)
        loginpage.input_username("李加驹")
        loginpage.input_password("li5127878")
        loginpage.click_submit()
        self.listpage.click_user()
        self.listpage.click_add()


    def all_options(self,name,email,address,zipcode,tel,mobile):
        #选项全填添加
        self.listpage.slect_province()
        time.sleep(3)
        self.listpage.slect_city()
        time.sleep(3)
        self.listpage.slect_district()
        self.listpage.input_name(name)
        self.listpage.input_email(email)
        self.listpage.input_address(address)
        self.listpage.input_zipcode(zipcode)
        self.listpage.input_tel(tel)
        self.listpage.input_mobile(mobile)
        time.sleep(3)
        self.listpage.click_submit()
        time.sleep(10)
        self.listpage.click_delete()
        time.sleep(3)
        self.listpage.click_aletor()
    def mandatory_options(self,name,email,address,tel):
        #必填项添加
        self.listpage.slect_province()
        time.sleep(3)
        self.listpage.slect_city()
        time.sleep(3)
        self.listpage.slect_district()
        time.sleep(3)
        self.listpage.input_name(name)
        self.listpage.input_email(email)
        self.listpage.input_address(address)
        self.listpage.input_tel(tel)
        self.listpage.click_submit()
        time.sleep(10)
        self.listpage.click_delete()
        time.sleep(3)
        self.listpage.click_aletor()

    def get_into_home(self):
        #跳转至首页
        self.listpage.click_home()

    def get_into_logout(self):
        #安全退出
        self.listpage.click_logout()
